function HandlePageBackendCourier(gui, operater, now, options) {
  this._gui = gui;
  this._source = operater;
  this._now = now;
  this._options = options;
    
  this._createElements();
};

HandlePageBackendCourier.prototype._createElements = function() {
  this._loadData();
};

HandlePageBackendCourier.prototype._loadData = function() {
  this._courier = null;
  this._retrieveCourier();
};

HandlePageBackendCourier.prototype._verifyData = function() {
  if (this._courier) {
    this._updateElements();
  }
};

HandlePageBackendCourier.prototype._retrieveCourier = function(page, condition, date, from, to, pos) {
  var _self = this;
  if (this._options.id) {
    /*new RequestUtils()._read('icourier', null, 'd.oid = ' + this._options.id, null, null, null, null, function(result, params) { _self._courier = (result.data.length == 1) ? result.data[0] : null;
                                                                                                                                 _self._verifyData.call(_self);
                                                                                                                               }, null);
  */
   var args = '&oid=' + this._options.id; 
  new RequestUtils()._mysql('icourier', args, function(result, params) { _self._courier = (result.data.length == 1) ? result.data[0] : null;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php'});   
  } else {
    this._courier = ICourier.instance();
    this._verifyData();
  }
};

HandlePageBackendCourier.prototype._updateElements = function() {
  var _self = this;

  this._gui.name.value = this._courier.name;
  this._gui.name.onchange = function() { _self._courier.name = this.value; };
  
  this._gui.save.onclick = function() { new RequestUtils()._mwrite('icourier', [_self._courier], [], function() { location.href = '?p=pagefactory&t=pagebackendcouriers&m=' + JSON.stringify({ a: 2, b: 2 }); }, null); };
  this._gui.cancel.onclick = function() { location.href = '?p=pagefactory&t=pagebackendcouriers&m=' + JSON.stringify({ a: 2, b: 2 }); };
};

